package com.itheima.day10.myStream.test8;

import com.itheima.day01.managerTest.domain.Student;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Demo {
    public static void main(String[] args) {
        ArrayList<String> man = new ArrayList<>(List.of("张三","张大帅","潇洒哥","黑大帅","陈奕迅","刘德华"));
        ArrayList<String> woman = new ArrayList<>(List.of("邓紫棋","杨邓丽君","杨曹云云","曾莉莉","杨丽君","杨过"));

        Stream<String> streaMan = man.stream().filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.length() == 3;
            }
        }).limit(2);

        Stream<String> streamWomen = woman.stream().filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                String str = s.charAt(0) + "";
                return "杨".equals(str);
            }
        }).skip(1);

        Stream<String> streamConcat = Stream.concat(streaMan, streamWomen);
        List<String> collect = streamConcat.collect(Collectors.toList());
        ArrayList<Actor> al = new ArrayList<>();
        for (String s : collect) {
            Actor a = new Actor(s);
            al.add(a);
        }
        System.out.println(al);
    }
}
